<template>
	<view>
		<view class="facility-container">
			<view class="title">
				<view class="left">单元信息</view>
				<view class="right">
					<text class="add" @click="onShow">
						+
					</text>
					<text @click="showAdd" style="color: #5094FF;">新增单元</text>
					<text class="more" @click="goMore">查看更多</text>
				</view>
			</view>
			<view class="info">
				<view v-if="unitList">
					<view class="info-item" v-for="(item,index) in unitList" :key="index">
						<view>
							<view class="info-wrap">单元名称：{{item['单元名称']}}</view>
							<!-- <view class="info-wrap">单元编号：{{item['单元编号']}}</view> -->
						</view>
						<!-- <view class="arrow"></view> -->
						<view class="edit" @click.stop="onEdit(item)">编辑</view>
						<view class="delete" @click.stop="onDelete(item.单元id)">删除</view>
					</view>
				</view>
				<view v-else class="empty">暂无单元</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['unitList'],
		data() {
			return {

			};
		},
		methods: {
			showAdd() {
				this.$emit('add')
			},
			onDelete(id) {
				this.$emit('delete', id)
			},
			onEdit(item) {
				this.$emit('edit', item)
			},
			goMore() {
				this.$emit('more')
			}
		}
	}
</script>

<style lang="scss">
	.title {
		padding: 0 14rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 40rpx;
		font-size: 34rpx;

		.left {
			font-size: 32rpx;

			&:before {
				content: '';
				position: absolute;
				top: 24rpx;
				left: 24rpx;
				width: 6rpx;
				height: 34rpx;
				background-color: #5094FF;
			}
		}

		.add {
			font-size: 32rpx;
			font-weight: bold;
			color: #5094FF;
			margin-right: 10rpx;
		}
	}

	.info {
		margin-left: 16rpx;

		// display: flex;
		// justify-content: center;
		// align-items: center;
		.empty {
			// width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			height: 174rpx;
			color: #999;
		}

		.info-item {
			position: relative;
			box-shadow: 0px 1px 6rpx 0px #EEEEEE;
			border-radius: 8rpx;
			margin-bottom: 10rpx;
			font-size: 32rpx;

			.info-title {
				margin-bottom: 20rpx;
			}

			.info-wrap {
				line-height: 50rpx;
				font-size: 28rpx;
			}

			.arrow {
				position: absolute;
				top: 20rpx;
				right: 40rpx;
				width: 20rpx;
				height: 20rpx;
				border-top: 2rpx solid #333;
				border-right: 2rpx solid #333;
				transform: rotate(45deg);
			}

			.delete {
				position: absolute;
				right: 20rpx;
				bottom: 10rpx;
				text-align: center;
				line-height: 35rpx;
				width: 70rpx;
				height: 35rpx;
				font-size: 22rpx;
				color: #E57544;
				border: 2rpx solid #E57544;
			}
		}
	}
</style>
